package com.ysd.lis.service.inv.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysd.common.Result;
import com.ysd.lis.entity.inv.InvInstrManage;
import com.ysd.lis.mapper.inv.InvInstrManageMapper;
import com.ysd.lis.service.inv.InvInstrManageService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 仪器仓库 服务实现类
 * </p>
 *
 * @author WH
 * @since 2024-09-12
 */
@Service
public class InvInstrManageServiceImpl extends ServiceImpl<InvInstrManageMapper, InvInstrManage> implements InvInstrManageService {

    @Autowired
    private InvInstrManageMapper invInstrManageMapper;

    @Override
    public Result findInstrManageList(InvInstrManage invInstrManage) {
        LambdaQueryWrapper<InvInstrManage> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        //参数
        if (!StringUtils.isEmpty(invInstrManage.getSearchValue())) {
            lambdaQueryWrapper.and(wrapper ->
                    wrapper.like(InvInstrManage::getInstrCode, invInstrManage.getSearchValue()).or().like(InvInstrManage::getInstrName, invInstrManage.getSearchValue()));
        }
        lambdaQueryWrapper.eq(InvInstrManage::getDelFlag, 0);
        lambdaQueryWrapper.eq(InvInstrManage::getStoreId, invInstrManage.getStoreId());
        lambdaQueryWrapper.orderByAsc(InvInstrManage::getSeq);
        List<InvInstrManage> invUserManages = invInstrManageMapper.selectList(lambdaQueryWrapper);
        return Result.succ(1, "查询成功", invUserManages);
    }
}
